<%@ page language="java" pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
${aier_doctype}
<html <s:property value="aier_html_xmlns" escape="false"/>>
<head>
<meta http-equiv="Content-Type" content="${aier_content_type}" />
<meta name="keywords" content="${aier_keyworks}" />
<meta name="description" content="${aier_description}" />
<title>${aier_title}</title>
<link rel="stylesheet" href="${aier_css_url}${aier_jqui_css}ui.css" />
<link rel="Stylesheet" href="${aier_css_url}jq/jq.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/jq-msg.css" />

<link rel="stylesheet" href="${aier_css_url}social/module/reset.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/icon.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/btn.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/emotion.css" />
<link rel="Stylesheet" href="${aier_css_url}social/module/homeside.css" />
<link rel="stylesheet" href="${aier_css_url}social/user/userMessage/usermessage.css" />
<link rel="stylesheet" href="${aier_css_url}social/module/xxs.css" />

<script type="text/javascript" src="${aier_js_url}j.js"></script>
<script type="text/javascript" src="${aier_js_url}b.js"></script>
<script type="text/javascript" src="${aier_js_url}${aier_jqui_js}ui.js"></script>
<script type="text/javascript" src="${aier_js_url}jp/msg.js"></script>
<script type="text/javascript" src="${aier_js_url}97/WdatePicker.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/cn.js"></script>
<script type="text/javascript" src="${aier_js_url}jq/jq.js"></script>
<script type="text/javascript" src="${aier_js_url}lib/block.js"></script>
<script type="text/javascript"
	src="${aier_js_url}emotion/xxsemotion.2.js"></script>
<script type="text/javascript" src="${aier_js_url}trantime/jquery-aier.js"></script>

</head>
<body>

	<!-- 顶栏 -->
	<s:action name="userhomecomm_homeHead" namespace="/user" executeResult="true"></s:action>
	<!-- 顶栏结束 -->


	<div class="window-content">

		<!-- wrap  -->
		<div class="wrap wrap-msg wrap-msg-praise clearfix">

			<!-- 主侧栏 -->
			<s:action name="usermessage_msgSide" namespace="/user" executeResult="true"></s:action>


			<!-- 主区域 (右  -->
			<div class="msg-main clearfix">
				<div class="msg-stream">
					<div class="msg-title">
						<div class="group">收到的赞</div>
					</div>
					<div id = "praise" class="clearfix">
						<div class="msg-title-function">
							
						</div>
						
						<div class="msg-stream">
	
						</div>
					</div>
                    <div id = "page"></div>
				</div>

				<!-- 右栏 -->
				<s:action name="userhomecomm_homeRight" namespace="/user" executeResult="true"></s:action>


			</div>
			<!-- 回到顶部 -->
			<s:action name="userhomecomm_backToTop" namespace="/user" executeResult="true"></s:action>
			<!-- 回到顶部结束  -->


		</div>
		<!-- footer copyright -->
		<s:action name="userhomecomm_homeFooter" namespace="/user" executeResult="true"></s:action>
		<!-- /footer copyright -->
	</div>
	
<script type="text/javascript">
var page = 1;       // 当前页
var page_size = 10; // 每页的记录数

    // 转换时间
    $(document).ready(function() {
        $('.msg-date').each(function() {
            $(this).tranTime();
        });
    });
    
	$(document).ready(function() {
	
        // 获取关注分组
        var fun=function(data){
            if(data.s==1){
            
                var c = "";
                for (var i=0;i<data.fgList.length;i++) {
                    if (data.fgList[i].name == "特别关注") {
                        c += "<div class='tab-normal'><a class='btn' href='${aier_url}user/userhomeforums_homeForums.shtml?fgid="+data.fgList[i].fgid+"'><em class='icon-1 icon-1-teguan'></em><span>"+data.fgList[i].name+"</span></a></div>";
                    } else {
                        c += "<div class='tab-normal'><a class='btn' href='${aier_url}user/userhomeforums_homeForums.shtml?fgid="+data.fgList[i].fgid+"'><em class='icon-1 icon-1-weifen'></em><span>"+data.fgList[i].name+"</span></a></div>";
                    }
                    
                }
                $("#group").html(c);
                
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}usermyfollow_searchFollowGroup${aier_suffix}"),
             fun,{
        });
        searchAppraise(page);
    });
    
    // 获取收到的赞
    function searchAppraise(nowpage) {
    	page = nowpage;
        var fun=function(data){
            if(data.s==1){
                var html = "";
                if (data.fpList == null || data.fpList.length == 0) {
                    html += '\<div class\=\"msg-title-function\"\>还没有人赞过你的新鲜事\<\/div\>';
                } else {
                    html += '<div class="msg-title-function">共'+data.count+'条</div>';
                    html += '<div class="msg-stream">';
                    for (var i=0;i<data.fpList.length;i++) {
                        var fp = data.fpList[i];
                        html += '<div class="msg-item type-praise"><div class="msg-avatar"><a href="${aier_url}user/uccomm_userCenter.shtml?in_uid='+fp.uid+'"><img src="${get_picturl_url}small/'+fp.headimg+'" alt=""></a> </div>';
                        html += '<div class="msg-content"><div class="title title-praise">'+fp.nickname+'<span>赞了你的内容<em class="icon-1 icon-1-praise"></em></span></div><div class="text">'+fp.fresh.content+'</div><div class="date"><span>'+fp.cdate.split("T")[0]+" "+fp.cdate.split("T")[1]+'</span></div></div></div>';
                    }
                    html += '</div>';
                }
                
                $("#praise").html(html);
                $("#praise .text").each(function(){
                	$(this).tranText({
                		emotionUrl: '${aier_js_url}trantime/emotions.js'
                	});
                });
                // 更新分页显示
                page = data.page;
                toLoadPage(page, page_size, data.page_count, data.count, "page", "searchAppraise", null, null);  
                if (data.count == 0) {
                    $("#page").css("display","none");
                } else {
                    $("#page").css("display","block");
                }
            }
        };
        exeAjax(
             ajaxUrl("${aier_url}${aier_urijs}usermessage_searchPraiseMyFresh${aier_suffix}"),
             fun,{
             "page":page,
             "page_size":page_size
        });
    }
    
    // 跳转到家校联系薄
    function hsConBook() {
        // 判断是否付费

        // 判断身份（家长或老师）

        // 教师（tid）
        //window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?tid=2&&cid=1";
        var fun = function(data) {
            if (data.s == 1) {

                if (data.type == 0) {
                    $().message("您目前没有权利进入家校联系薄！");
                    return;
                } else if (data.type == 1 || data.type == 3) {
                    if (data.classList != null && data.classList.length > 0) {
                        window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?cid="
                                + data.classList[0].cid +"&type="+data.type;
                    } else {
                        window.location.href = "${aier_url}user/userhscb_userTeaHSConBook.shtml?type="+data.type;
                    }

                } else if (data.type == 2) {
                    window.location.href = "${aier_url}user/userhscb_userChiHSConBook.shtml?type="+data.type;
                }

            }
        };
        exeAjax(
                ajaxUrl("${aier_url}${aier_urijs}userhscb_searchClassList${aier_suffix}"),
                fun, {});

    }
</script>

</body>
</html>